﻿'''
242有效的字母异位词
给定两个字符串 s 和 t ，编写一个函数来判断 t 是否是 s 的 字母异位词。
示例 1:
输入: s = "anagram", t = "nagaram"
输出: true
示例 2:
输入: s = "rat", t = "car"
输出: false
提示:
1 <= s.length, t.length <= 5 * 104
s 和 t 仅包含小写字母
进阶: 如果输入字符串包含 unicode 字符怎么办？你能否调整你的解法来应对这种情况？
'''
class Solution:
    def isAnagram(self,s:str,t:str)->bool:
        dict_s = {}
        dict_t = {}
        for i in range(len(s)):
            if s[i] not in dict_s:
                dict_s[s[i]] = 1
            else:
                dict_s[s[i]] += 1
        for i in range(len(t)):
            if t[i] not in dict_t:
                dict_t[t[i]] = 1
            else:
                dict_t[t[i]] += 1
        return dict_s == dict_t
#示例
if __name__ == '__main__':
    s = "Abcdef你好"
    t = "bAc你好edf"
    s1 = "anagram"
    t1 = "nagaram"
    s2 = "rat" 
    t2 = "car"
    print(Solution().isAnagram(s,t))
    print(Solution().isAnagram(s1,t1))
    print(Solution().isAnagram(s2,t2))



